<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateQiiWebgroupTinyTable extends Migration
{
    /**
     * Schema table name to migrate
     * @var string
     */
    public $set_schema_table = 'qii_webgroup_tiny';

    /**
     * Run the migrations.
     * @table qii_webgroup_tiny
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable($this->set_schema_table)) return;
        Schema::create($this->set_schema_table, function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id')->comment('子站点ID');
            $table->unsignedInteger('user_id')->default('0')->comment('站点创建者ID');
            $table->string('key', 20)->default('')->comment('站点标识');
            $table->string('name', 180)->default('')->comment('站点名称');
            $table->text('description')->comment('站点介绍');
            $table->string('domain', 180)->default('')->comment('站点域名');
            $table->unsignedInteger('sortrank')->default('0')->comment('排序');
            $table->text('tpls')->comment('可选模板(逗号分隔多个)');
            $table->text('manager')->comment('站点管理人员(逗号分隔多个)');
            $table->unsignedInteger('modified')->default('0')->comment('添加/修改时间');
            $table->unsignedTinyInteger('status')->default('1')->comment('状态 (0关闭,1开启)');
            $table->text('config')->comment('站点配置');

            $table->index(["key", "status"], 'key_status');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
     public function down()
     {
       Schema::dropIfExists($this->set_schema_table);
     }
}
